import fetch from 'utils/fetch';

// 文章分页
export function selectArticle(page,rows,schoolId,typeId){
    const data = {
        page,
        rows,
        schoolId,//学校id
        typeId
    };
    return fetch({
        url: `article/selectArticle`,
        method: 'post',
        data,
    });
}
// 类型下拉
export function selectTypeName(schoolId){
    const data = {
        schoolId//学校id
    };
    return fetch({
        url: `article/selectTypeName`,
        method: 'post',
        data,
    });
}

// 新增类型
export function addNewType(schoolId,typeNameList,typeIdList){
    const data = {
        schoolId,//学校id
        typeNameList,//添加的类型的名字
        typeIdList//删除的类型的id
    };
    return fetch({
        url: `article/addNewType`,
        method: 'post',
        data,
    });
}

// 新建文章
export function createArticle(schoolId,title,typeId,showType,html,pic,creator,publisher,link){
    const data = {
        schoolId,//学校id
        title,//标题
        typeId,//类型id
        showType,//展现形式 0 链接 1 html'
        html,//html源码
        pic,//封面图片
        creator,//创建人
        publisher,//发布人
        link//链接地址
    };
    return fetch({
        url: `article/createArticle`,
        method: 'post',
        data,
    });
}

// 编辑分类

export function editType(schoolId){
    const data = {
        schoolId//学校id
    };
    return fetch({
        url: `article/editType`,
        method: 'post',
        data,
    });
}


// 编辑文章

export function editArticle(schoolId,articleId,title,typeId,showType,html,pic,
    creator,publisher,link){
    const data = {
        schoolId,//学校id
        articleId,//
        title,//标题
        typeId,//类型id
        showType,//展现形式
        html,//html源码
        pic,//封面图片
        creator,//创建人
        publisher,//发布人
        link
    };
    return fetch({
        url: `article/editArticle`,
        method: 'post',
        data,
    });
}


// 删除文章
export function deleteArticle(schoolId,articleId){
    const data = {
        schoolId,//学校id
        articleId//文章id
    };
    return fetch({
        url: `article/deleteArticle`,
        method: 'post',
        data,
    });
}

// 回填编辑页
export function editButton(articleId){
    const data = {
        articleId//文章id
    };
    return fetch({
        url: `article/editButton`,
        method: 'post',
        data,
    });
}

// @author shwj 20180424 查询该学校所有文章类别
export function getListArticleType(schoolId) {
    const data = {
        schoolId
    }
    return fetch({
        url:"/eCampus/listArticleType",
        method: 'post',
        data
    });
}

// @author shwj 20180424 查找某类别下所有文章
export function getListArticle(jsonData) {
    const data = {
        ...jsonData
    }
    return fetch({
        url: "/eCampus/listArticle",
        method: 'post',
        data
    });
}

// @author shwj 20180424 获取菜单设置Icon图
export function listCampusIcon() {
    return fetch({
        url: "/eCampus/listCampusIcon",
        method: 'post',
    });
}
// 保存预览图
export function insertCampusFrame(jsonData){
    const data = {
        ...jsonData
    };
    return fetch({
        url: "/eCampus/insertCampusFrame",
        method: 'post',
        data
    });
}
// 获取预览图
export function getCampusFrame(schoolId) {
    const data = {
        schoolId
    };
    return fetch({
        url: "/eCampus/getCampusFrame2",
        method: 'post',
        data
    });
}
// 发布预览图
export function updateCampusFrame(jsonData) {
    const data = {
        ...jsonData
    };
    return fetch({
        url: "/eCampus/updateCampusFrame",
        method: 'post',
        data
    });
}

// 图片添加水印
export function addPicWatermark(jsonData) {
    const data = {
        ...jsonData
    };
    return fetch({
        url: "/article/addPicWatermark",
        method: 'post',
        data
    });
}